<?php
namespace Home\Controller;
use Think\Controller;
Class ShopmallController extends Controller
{
    //县会长
    public function index()
    {
        $condition['user_open']  = 1;
		
        $condition['user_type']  = $user_type = I("post.type");

        $condition['user_state'] = 1;

        $condition['user_baby'] = array("egt",3);

        $shopmall = D("Index")->get_user_info($condition);

        $like = trim(I("post.user_username"));

        if ($like) {
            $shopmall = M("section_user")->where("user_username like '%$like%' and user_open = 1 and user_type = ".$user_type." and user_state = 1 and user_baby >= 3")->order("user_id desc")->select();
        }

        if ($shopmall) {
            foreach ($shopmall as $v) {
                $user_id[] = $v['user_id'];
            }
            foreach ($shopmall as $k => $v) {
                $goods_user_id = $v['user_id'];
                $shopmall[$k]['child'] = D("Goods")->get_goods_info(array('goods_user_id' => $goods_user_id,'goods_state' => 1), '', 3);
            }

        } else {
			$validate['code'] = 1;

			$validate['msg']  = "暂时没有匹配数据";      
			
			echo json_encode($validate);die;
			
		}
		$validate['code'] = 0;

        $validate['msg']  = "成功";

        $validate['data'] = $shopmall;

        echo json_encode($validate);die;
    }

    //每个县的商品特色
    public function more_goods()
    {
        $condition['user_id']    = intval(I("post.id"));
		
        $condition['user_state'] = 1;
		
		$get_user_one_info = D("Index")->get_user_one_info($condition);
		
		unset($condition['user_id']);
		
		unset($condition['user_state']);
        
		$condition['goods_user_id'] = intval(I("post.id"));

        $condition['goods_status']  = 1;
		
        $condition['goods_state']   = 1;
		
        $user_goods = D("Goods")->get_goods_info($condition);
		
		$validate['code'] = 0;

        $validate['msg']  = "成功";

        $validate['data_user_goods'] = $user_goods;    
		
        $validate['data_get_user_one_info'] = $get_user_one_info;    
        if (!$user_goods) {
			$validate['code'] = 1;

			$validate['msg']  = "暂时没有匹配数据";      
		}
		echo json_encode($validate);die;        
	}


}
?>


